package com.trdcore.zyzkt.controller;

import com.trdcore.zyzkt.resp.ResultData;
import com.trdcore.zyzkt.service.OrderInfoService;
import com.trdcore.zyzkt.vo.order.OrderFormVo;
import com.trdcore.zyzkt.vo.order.OrderInfoVo;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("api/order/orderInfo")
public class OrderInfoApiController {

    @Autowired
    private OrderInfoService orderInfoService;

    @Operation(summary = "新增点播课程订单",description = "新增点播课程订单")
    @PostMapping("submitOrder")
    public ResultData submitOrder(@RequestBody OrderFormVo orderFormVo, HttpServletRequest request) {
        //返回订单id
        Long orderId = orderInfoService.submitOrder(orderFormVo);
        return ResultData.success(orderId);
    }

    @Operation(summary = "获取",description = "获取")
    @GetMapping("getInfo/{id}")
    public ResultData getInfo(@PathVariable("id") Long id) {
        OrderInfoVo orderInfoVo = orderInfoService.getOrderInfoVoById(id);
        return ResultData.success(orderInfoVo);
    }
}